<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Page
 * @copyright  Copyright Hire-Experts LLC
 * @license    http://www.hire-experts.com
 * @version    $Id: edit.tpl 2010-08-31 17:53 idris $
 * @author     Idris
 */
?>

<div class="theme_<?php echo $this->activeTheme->name; ?>">

<?php if ($this->error): ?>
<ul class="form-errors"><li><ul class="errors"><li><?php echo $this->message; ?></li></ul></li></ul>
<?php return; endif; ?>

<?php 
	$this->headScript()
		->appendFile($this->baseUrl().'/externals/autocompleter/Observer.js')
    ->appendFile($this->baseUrl().'/externals/autocompleter/Autocompleter.js')
    ->appendFile($this->baseUrl().'/externals/autocompleter/Autocompleter.Local.js')
    ->appendFile($this->baseUrl().'/externals/autocompleter/Autocompleter.Request.js'); 
?>

<script type="text/javascript">
  en4.core.runonce.add(function()
  {
    new Autocompleter.Request.JSON('extra-tags', '<?php echo $this->url(array('controller' => 'tag', 'action' => 'suggest'), 'default', true) ?>', {
      'postVar' : 'text',
      'customChoices' : true,
      'minLength': 1,
      'selectMode': 'pick',
      'autocompleteType': 'tag',
      'className': 'tag-autosuggest',
      'filterSubset' : true,
      'multiple' : true,
      'injectChoice': function(token){
        var choice = new Element('li', {'class': 'autocompleter-choices', 'value':token.label, 'id':token.id});
        new Element('div', {'html': this.markQueryValue(token.label),'class': 'autocompleter-choice'}).inject(choice);
        choice.inputValue = token;
        this.addChoiceEvents(choice).inject(this.choices);
        choice.store('autocompleteChoice', token);
      }
    });
  });
</script>

<?php
  /* Include the common user-end field switching javascript */
  echo $this->partial('_jsSwitch.tpl', 'fields', array(
      'topLevelId' => (int) @$this->topLevelId,
      'topLevelValue' => (int) @$this->topLevelValue
    ))
?>

<script type="text/javascript">
page.page_id = <?php echo $this->page->getIdentity(); ?>;
page.ajax_url = "<?php echo $this->url(array('action' => 'ajax'), 'admin_general'); ?>";
window.addEvent('domready', function(){
	page.init();
});
</script>

<div class="page_edit_title">
  <div class="l">
  	<?php echo $this->htmlLink( $this->page->getHref(), $this->itemPhoto($this->page, 'thumb.icon') ); ?>
  </div>
  <div class="r">
    <h3><?php echo $this->page->getTitle(); ?></h3>
	  <div class="pages_layoutbox_menu">
	  <ul>
	    <li id="pages_layoutbox_menu_createpage">
	      <?php echo $this->htmlLink( $this->url(array(), 'page_create'), $this->translate('Create Page') ); ?>
	     </li>
	     <li id="pages_layoutbox_menu_viewpage">
	      <?php echo $this->htmlLink( $this->url(array( 'page_id' => $this->page->url ), 'page_view'), $this->translate('View Page') ); ?>
	     </li>
	     <li id="pages_layoutbox_menu_deletepage">
	      <?php echo $this->htmlLink( $this->url(array( 'action' => 'delete', 'page_id' => $this->page->page_id), 'page_team'), $this->translate('Delete Page') ); ?>
	     </li>
	  </ul>
	  </div>
  </div>
  <div class="clr"></div>
</div>
<div class="clr"></div>

<div class='layout_right'>

  <div class="page_statistics global_form_box">
    <h3><?php echo $this->translate("Statistics"); ?></h3>
    <table width="100%" cellpadding="0" cellspacing="0">
      <tbody>
        <tr>
          <td class="label"><?php echo $this->translate("Likes"); ?>:</td>
          <td class="value"><?php echo $this->page->getLikesCount(); ?></td>
        </tr>
        <tr>
          <td class="label"><?php echo $this->translate("Unique Visitors"); ?> *</td>
          <td class="value"><?php echo $this->page->getTotalVisitorsCount(); ?></td>
        </tr>
        <tr>
          <td class="label"><?php echo $this->translate("Page Views"); ?> *</td>
          <td class="value"><?php echo $this->page->getTotalViewsCount(); ?></td>
        </tr>
      </tbody>
    </table>
    <div>* <?php echo $this->translate("Data for last 30 days"); ?></div>
    <?php echo $this->htmlLink($this->url(array('page_id' => $this->page->getIdentity()), 'page_stat'), $this->translate('View Detailed Statistics')); ?>
  </div>
  <br />

  <div class="page_edit_admins global_form_box">
    <h3>
      <?php echo $this->translate("Admins"); ?>
    </h3>
    <?php echo $this->htmlLink("javascript:page.choose_admins();", $this->translate("Add")); ?>
    <br class="clr" />
		<?php if ($this->admins->getTotalItemCount() > 0): ?>    
    <div class="page_admin_list">
	    <?php foreach ($this->admins as $admin): ?>
			<div class="page_admin_list_item">
				<div class="l">
					<?php echo $this->htmlLink($admin->getHref(), $this->itemPhoto($admin, 'thumb.icon', '', array('class' => 'thumb_icon item_photo_user')), array('class' => 'admin_profile_thumb')); ?>
				</div>
				<div class="r">
					<?php echo $this->htmlLink($admin->getHref(), $admin->getTitle(), array('class' => 'page_admin')); ?>
					<div class="team_box">
						<span class="team_title" id="admin_title_<?php echo $admin->getIdentity(); ?>"><?php echo $admin->title ? $admin->title : 'Admin'; ?></span>
						<a class="team_title_edit" id="admin_title_edit_<?php echo $admin->getIdentity(); ?>" href="javascript:page.edit_admin_title(<?php echo $admin->getIdentity(); ?>);">&nbsp;</a>
						<div class="team_title_input_box hidden" id="admin_title_input_box_<?php echo $admin->getIdentity(); ?>">
						<input class="team_title_input" type="text" value="<?php echo $admin->title ? $admin->title : 'Admin'; ?>" id="admin_title_input_<?php echo $admin->getIdentity(); ?>" />
						</div>
						<div class="clr"></div>
					</div>
					<?php if ($this->page->user_id != $admin->getIdentity()): ?>
		      	<?php echo $this->htmlLink($this->url(array('action' => 'remove', 'admin_id' => $admin->getIdentity()), 'admin_specific')."?page_id=".$this->page->getIdentity(), $this->translate("Remove Admin")); ?>
		      <?php endif; ?>
	    	</div>
	    	<br class="clr" />
			</div>
			<?php endforeach; ?>
    </div>
    <?php endif; ?>
    <div class="clr"></div>
  </div>
  
</div>

<div class='layout_middle'>
  


    <div class="global_form_box">
      <div class="page_edit_info">
        <div class="page_edit_title"><?php echo $this->translate("Information"); ?></div>
        <div class="page_edit_options">
        <?php if ($this->edit == 'info'): ?>
        	<?php echo $this->htmlLink("javascript:void(0)", $this->translate('Edit'), array("id" => "page_edit_edit_info", "class" => "hidden", "onclick" => "toggle_page_edit_tab(this.id, 'page_edit_hide_info', 'page_edit_form_info', 'page_edit_desc_info', true);")); ?>
        	<?php echo $this->htmlLink("javascript:void(0)", $this->translate('Hide'), array("id" => "page_edit_hide_info", "onclick" => "toggle_page_edit_tab(this.id, 'page_edit_edit_info', 'page_edit_form_info', 'page_edit_desc_info', false);")); ?>
        <?php else: ?>
          <?php echo $this->htmlLink("javascript:void(0)", $this->translate('Edit'), array("id" => "page_edit_edit_info", "onclick" => "toggle_page_edit_tab(this.id, 'page_edit_hide_info', 'page_edit_form_info', 'page_edit_desc_info', true);")); ?>
          <?php echo $this->htmlLink("javascript:void(0)", $this->translate('Hide'), array("id" => "page_edit_hide_info", "class" => "hidden", "onclick" => "toggle_page_edit_tab(this.id, 'page_edit_edit_info', 'page_edit_form_info', 'page_edit_desc_info', false);")); ?>
        <?php endif; ?>
        </div>
        <div class="page_edit_desc" id="page_edit_desc_info"><?php echo $this->translate('Edit your Page title, description, location and other information.'); ?></div>
        <?php echo $this->fieldForm->render($this); ?>
      </div>
    </div>
    <br />

    <div class="global_form_box">
      <div class="page_edit_privacy">
        <div class="page_edit_title"><?php echo $this->translate("Privacy Settings"); ?></div>
        <div class="page_edit_options">
        <?php if ($this->edit == 'privacy'): ?>
	        <?php echo $this->htmlLink("javascript:void(0)", $this->translate('Edit'), array("id" => "page_edit_edit_privacy", "class" => "hidden", "onclick" => "toggle_page_edit_tab(this.id, 'page_edit_hide_privacy', 'page_edit_form_privacy', 'page_edit_desc_privacy', true);")); ?>
	        <?php echo $this->htmlLink("javascript:void(0)", $this->translate('Hide'), array("id" => "page_edit_hide_privacy", "onclick" => "toggle_page_edit_tab(this.id, 'page_edit_edit_privacy', 'page_edit_form_privacy', 'page_edit_desc_privacy', false);")); ?>
	      <?php else: ?>
	        <?php echo $this->htmlLink("javascript:void(0)", $this->translate('Edit'), array("id" => "page_edit_edit_privacy", "onclick" => "toggle_page_edit_tab(this.id, 'page_edit_hide_privacy', 'page_edit_form_privacy', 'page_edit_desc_privacy', true);")); ?>
          <?php echo $this->htmlLink("javascript:void(0)", $this->translate('Hide'), array("id" => "page_edit_hide_privacy", "class" => "hidden", "onclick" => "toggle_page_edit_tab(this.id, 'page_edit_edit_privacy', 'page_edit_form_privacy', 'page_edit_desc_privacy', false);")); ?>
	      <?php endif; ?>
        </div>
        <div class="page_edit_desc" id="page_edit_desc_privacy"><?php echo $this->translate('Edit your Page privacy settings: who can view, post content, etc.'); ?></div>
        <?php echo $this->privacyForm->render($this); ?>
      </div>
    </div>
    <br />

    <div class="global_form_box">
      <div class="page_edit_photo">
        <div class="page_edit_title"><?php echo $this->translate('Photo'); ?></div>
        <div class="page_edit_options">
        <?php if ($this->edit == 'photo'): ?>
        	<?php echo $this->htmlLink("javascript:void(0)", $this->translate('Edit'), array("id" => "page_edit_edit_photo", "class" => "hidden", "onclick" => "toggle_page_edit_tab(this.id, 'page_edit_hide_photo', 'page_edit_form_photo', 'page_edit_desc_photo', true);")); ?>
	        <?php echo $this->htmlLink("javascript:void(0)", $this->translate('Hide'), array("id" => "page_edit_hide_photo", "onclick" => "toggle_page_edit_tab(this.id, 'page_edit_edit_photo', 'page_edit_form_photo', 'page_edit_desc_photo', false);")); ?>
	      <?php else: ?>
	        <?php echo $this->htmlLink("javascript:void(0)", $this->translate('Edit'), array("id" => "page_edit_edit_photo", "onclick" => "toggle_page_edit_tab(this.id, 'page_edit_hide_photo', 'page_edit_form_photo', 'page_edit_desc_photo', true);")); ?>
          <?php echo $this->htmlLink("javascript:void(0)", $this->translate('Hide'), array("id" => "page_edit_hide_photo", "class" => "hidden", "onclick" => "toggle_page_edit_tab(this.id, 'page_edit_edit_photo', 'page_edit_form_photo', 'page_edit_desc_photo', false);")); ?>
	      <?php endif; ?>
        </div>

        <div class="page_edit_desc <?php if ($this->edit == 'photo') echo "hidden"; ?>" id="page_edit_desc_photo"><?php echo $this->translate('Edit your Page photo.') ?></div>

        <div class="page_edit_form <?php if ($this->edit != 'photo') echo "hidden"; ?>" id="page_edit_form_photo">
          <div class="form-elements">
            <div class="page_edit_photo_current">
            	<?php echo $this->itemPhoto($this->page, 'thumb.profile'); ?>
            	<?php if ($this->page->photo_id > 0): ?>            	
            	<?php echo $this->htmlLink($this->url(array('action' => 'delete-photo', 'page_id' => $this->page->page_id), 'page_team'), $this->translate('Delete Photo')); ?>
            	<?php endif; ?>
            </div>
            <div class="page_edit_photo_new">
              <?php echo $this->photoForm->render($this); ?>
            </div>
            <br class="clr" />
          </div>
        </div>
      </div>
    </div>
    <br />

    <div class="global_form_box">
      <div class="page_edit_layout">
        <div class="page_edit_title"><?php echo $this->translate("Layout"); ?></div>
        <div class="page_edit_options">
        	<?php echo $this->htmlLink($this->url(array('action' => 'index', 'page' => $this->page->page_id), 'page_editor'), $this->translate('Edit')); ?>
        </div>
        <div class="page_edit_desc" id="page_edit_desc_layout"><?php echo $this->translate('Edit your Page layout - add new wid, change apps position, etc.'); ?></div>
      </div>
    </div>



</div>

</div>